import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.stream.Stream;

public class day_01_stream_2 {
    public static void main(String[] args) {
        // 单列集合使用stream流
        System.out.println("-------------------单列集合使用stream流--------------------");
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list, "a", "b", "c");
        list.stream().forEach(s -> System.out.print(s + " "));
        System.out.println();

        // 双列集合使用stream流
        System.out.println("--------------------双列集合使用stream流-------------------");
        HashMap<String, Integer> hashMap = new HashMap<>();
        hashMap.put("A", 1);
        hashMap.put("B", 2);
        hashMap.put("C", 3);
        hashMap.keySet().stream().forEach(key -> System.out.print(key + " ")); // 获取键
        hashMap.entrySet().stream().forEach(s -> System.out.print(s + " ")); // 获取键值对
        System.out.println();
        // 数组获取stream流
        System.out.println("---------------------数组使用stream流----------------------");
        int[] arr = { 1, 2, 3, 4, 5 }; // 基本数据类型
        String[] arr1 = { "a", "b", "c" }; // 引用数据类型

        Arrays.stream(arr).forEach(s -> System.out.print(s + " "));
        System.out.println();
        Arrays.stream(arr1).forEach(s -> System.out.print(s + " "));
        System.out.println();

        //零散数据类型
        System.out.println("---------------------零散数据类型----------------------");
        Stream.of(1,2,3,"a","c",true).forEach(s -> System.out.print(s + " "));
    }
}
